package com.jianganming.template.jdbc.framework;

public class JdbcConfig {
    private JdbcTemplate jdbcTemplate;

    private static final JdbcConfig JDBC_CONFIG = new JdbcConfig();

    private JdbcConfig(){
        DataSource dataSource = getDataSource();
        this.jdbcTemplate = new JdbcTemplate(dataSource);
    }

    public JdbcTemplate getJdbcTemplate(){
        return this.jdbcTemplate;
    }

    private static DataSource getDataSource(){
        DataSource dataSource = new DataSource();
        dataSource.setUrl("jdbc:mysql://localhost:3306/leyou?useUnicode=true&characteEncodeing=UTF-8");
        dataSource.setUserName("root");
        dataSource.setPassword("123456");
        return dataSource;
    }

    public static JdbcConfig getInstance(){
        return JDBC_CONFIG;
    }

}
